﻿using System.Windows;
using System.Windows.Controls;
using Project5188.BUS.SalesAndCustomerRelations;

namespace Project5188.Client.SalesAndCustomerRelations.Reports
{
    /// <summary>
    /// Interaction logic for OfferReportWindow.xaml
    /// </summary>
    public partial class OfferReportWindow
    {
        public OfferReportWindow(long id)
        {
            InitializeComponent();

            BindData(id);
        }

        private void BindData(long id)
        {
            var offers = new Offers();
            var offer = offers.GetEntityById(id);
            if (offer.Count <= 0) return;

            lblCompanyLetterhead.Content = offer[0].c_CompanyLetterhead;
            lblCompanyName.Content += " " + offer[0].customerinfo.b_CompanyName;
            lblContentDate.Content = offer[0].d_ContentDate.ToShortDateString();

            txtCompanyAddress.Text = offer[0].customerinfo.f_CompanyAddress;
            txtOfferDetail.Text = offer[0].f_OfferDetail;
            txtTextContent.Text = offer[0].e_TextContext;
            txtCompanyInfo.Text = offer[0].customerinfo.b_CompanyName + "\n" +
                                  offer[0].customerinfo.f_CompanyAddress;
        }

        private void BtnPrintClick(object sender, RoutedEventArgs e)
        {
            BtnPrint.Visibility = Visibility.Hidden;

            var printDlg = new PrintDialog();

            if (printDlg.ShowDialog() != true) return;

            printDlg.PrintVisual(this, "Teklif Bilgileri");

            BtnPrint.Visibility = Visibility.Visible;
        }
    }
}
